<!DOCTYPE html>
<html>
<head>
    <title>私人订制：明信片和个性化邮票</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!-- head 中 -->
    <link rel="stylesheet" th:href="@{/jquery-weui/lib/weui.css}">
    <link rel="stylesheet" th:href="@{/jquery-weui/css/jquery-weui.css}">
    <link rel="stylesheet" th:href="@{/jquery-weui/css/demos.css?t=12}">

    <style>
        html{
            height: 100%;
        }
        body{
            width: 100%;
            height:100%;
        }
        *{
            margin: 0;
            padding: 0;
        }
        .weui-tabbar__label{
            font-size: 22px;
        }
    </style>
</head>

<body>
<div class="weui-tab">
    <div class="weui-tab__bd">
        <div id="tab1" class="weui-tab__bd-item weui-tab__bd-item--active">
            <iframe id="tab1_a" src="" style="width: 100%;height: 100%;frameborder:no;border: 0;scrolling:yes;allowtransparency:yes"></iframe>
        </div>
        <div id="tab2" class="weui-tab__bd-item">
            <iframe id="tab2_a" src="" style="width: 100%;height: 100%;frameborder:no;border: 0;scrolling:yes;allowtransparency:yes"></iframe>
        </div>
        <div id="tab3" class="weui-tab__bd-item">
            <iframe id="tab3_a" src="" style="width: 100%;height: 100%;frameborder:no;border: 0;scrolling:yes;allowtransparency:yes"></iframe>
        </div>
    </div>

    <div class="weui-tabbar">
        <a href="#tab1" class="weui-tabbar__item weui-bar__item--on">
            <div class="weui-tabbar__icon">
                <img src="/stamp/image/icon-index.png" alt="" style="width: 32px;height: 32px;">
            </div>
            <p class="weui-tabbar__label">首页</p>
        </a>
        <a href="#tab2" class="weui-tabbar__item">
            <div class="weui-tabbar__icon">
                <img src="/stamp/image/icon-work.png" alt="" style="width: 32px;height: 32px;">
            </div>
            <p class="weui-tabbar__label">我的作品</p>
        </a>
        <a href="#tab3" class="weui-tabbar__item">
            <div class="weui-tabbar__icon">
                <img src="/stamp/image/icon-order.png" alt="" style="width: 32px;height: 32px;">
            </div>
            <p class="weui-tabbar__label">订单</p>
        </a>
    </div>
</div>
<!-- body 最后 -->
<script type="text/javascript" th:src="@{/jquery-weui/lib/jquery-2.1.4.js}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/jquery-weui/lib/fastclick.js}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/jsfiles/jweixin-1.6.0.js}" charset="utf-8"></script>
<script>
    $(function() {
        FastClick.attach(document.body);
    });
    var id = "[[${id}]]";
    var adminUrl = "[[${adminUrl}]]";
    var dz = window.location.href;
    var dz1 = dz.replace(/&/g, "$");
    //后端地址
    var url = "[[${serverUrl}]]/stamp/h5/api/";
    $("#tab1_a").attr("src",adminUrl+"/h5/card/show_hd?xm_id="+encodeURIComponent(id));
    $("#tab2_a").attr("src",adminUrl+"/h5/card/wdzp?xm_id="+encodeURIComponent(id));
    $("#tab3_a").attr("src",adminUrl+"/h5/card/myorder?xm_id="+encodeURIComponent(id));

    function fx(a,b,c,d){
        try {
            wx.config({
                debug: false,
                appId: a,
                timestamp: b,
                nonceStr: c,
                signature: d,
                jsApiList: [
                    'updateAppMessageShareData  ',
                    'updateTimelineShareData',
                ]
            });
            wx.ready(function () {   //需在用户可能点击分享按钮前就先调用
                wx.updateAppMessageShareData({
                    title: '武汉邮政个性化定制', // 分享标题
                    desc: '武汉邮政个性化定制', // 分享描述
                    link: window.location.href, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                    imgUrl: '', // 分享图标
                    success: function () {
                        // 设置成功
                    }
                })
                wx.updateTimelineShareData({
                    title: '武汉邮政个性化定制', // 分享标题
                    link: window.location.href, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                    imgUrl: '', // 分享图标
                    success: function () {
                        // 设置成功
                    }
                })
            });
            wx.error(function (res) {
                //alert(res.errMsg);
            });
        }catch (e) {
            //alert(e);
        }
    }

    $.ajax({
        type:"post",
        url:url+"check_login",
        data:"{\"dz\":\""+dz+"\"}",
        dataType:"json",
        timeout : 10*1000, //超时时间设置，单位毫秒
        crossDomain: true,
        contentType: 'application/json;charset=UTF-8',
        headers: {
            "token": localStorage.getItem("token_h5") // 在请求头中添加token
        },
        beforeSend: function(request) {
            request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
        },
        success:function(result){
            console.info(JSON.stringify(result));
            if (result.code==6) window.location.href = adminUrl+"/h5/login?backurl=" + encodeURIComponent(dz1);
            if (result.code==200){
                let a = JSON.parse(result.data);
                fx(a.appid,a.timestamp,a.nonceStr,a.signature);
            }

        },
        error:function(result){
            $.alert("页面加载发生错误！请刷新！");
        }
    });
</script>
<script type="text/javascript" th:src="@{/jquery-weui/js/jquery-weui.js}" charset="utf-8"></script>
</body>
</html>
